#include "EntGhost.h"

EntGhost::EntGhost(vect _color) {
	color = _color;
	roto = 0;
}

void EntGhost::think() {
	// game logic goes here for an Ent
	// can access the map with
	// handler->

	roto = (roto + 3) % 360;
}

void EntGhost::draw() {
	// display logic goes here
	// draw the object at 0,0,0
	// x,y are the gameboard, z is 0 for the level
	// remember Z is up now

	//Draw ghosts
	GLUquadric *myQuad;

	myQuad=gluNewQuadric();
	bool wireFrame = 0;
	if (wireFrame == 0 )
		gluQuadricDrawStyle(myQuad, GLU_FILL);
	else
		gluQuadricDrawStyle(myQuad, GLU_LINE);

	glColor3dv(color);

	glPushMatrix();
		// top
		glRotatef (90, 1, 0, 0.0);
		gluSphere(myQuad, 6, 20, 20);
		glRotatef (90,1, 0,0);

		// middle
		gluCylinder(myQuad, 6, 6, 9, 50, 20);
		glTranslatef (0,0, 9);
		gluDisk(myQuad, 0, 6, 50, 20);
	
		// bottom
		for (int angle = 0; angle < 360; angle += 40) {
			glPushMatrix();
				glRotatef (angle + roto, 0,0,1);
				glTranslatef (4.5,0,0);
				gluCylinder(myQuad, 1.5,  0, 3, 50, 20);
			glPopMatrix();
		}
	glPopMatrix();

	// eyes
	glPushMatrix();
		glColor3f(1,1,1);
		glTranslated(4,4,1);
		glutSolidSphere(2,8,8);

		glColor3f(0,0,0);
		glTranslated(0,2,0);
		glutSolidSphere(1,8,8);
	glPopMatrix();
	glPushMatrix();
		glColor3f(1,1,1);
		glTranslated(-4,4,1);
		glutSolidSphere(2,8,8);

		glColor3f(0,0,0);
		glTranslated(0,2,0);
		glutSolidSphere(1,8,8);
	glPopMatrix();
}
